package com.ruoyi.salesman.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.salesman.domain.SalesmanApply;
import com.ruoyi.salesman.service.ISalesmanApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务员审核Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/salesmanApply/salesmanApply")
public class SalesmanApplyController extends BaseController
{
    @Autowired
    private ISalesmanApplyService salesmanApplyService;

    /**
     * 查询业务员审核列表
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(SalesmanApply salesmanApply)
    {
        startPage();
        List<SalesmanApply> list = salesmanApplyService.selectSalesmanApplyList(salesmanApply);
        return getDataTable(list);
    }

    /**
     * 导出业务员审核列表
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:export')")
    @Log(title = "业务员审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SalesmanApply salesmanApply)
    {
        List<SalesmanApply> list = salesmanApplyService.selectSalesmanApplyList(salesmanApply);
        ExcelUtil<SalesmanApply> util = new ExcelUtil<SalesmanApply>(SalesmanApply.class);
        util.exportExcel(response, list, "业务员审核数据");
    }

    /**
     * 获取业务员审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(salesmanApplyService.selectSalesmanApplyById(id));
    }

    /**
     * 新增业务员审核
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:add')")
    @Log(title = "业务员审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SalesmanApply salesmanApply)
    {
        return toAjax(salesmanApplyService.insertSalesmanApply(salesmanApply));
    }

    /**
     * 修改业务员审核
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:edit')")
    @Log(title = "业务员审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SalesmanApply salesmanApply)
    {
        return toAjax(salesmanApplyService.updateSalesmanApply(salesmanApply));
    }

    /**
     * 删除业务员审核
     */
    @PreAuthorize("@ss.hasPermi('salesmanApply:salesmanApply:remove')")
    @Log(title = "业务员审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(salesmanApplyService.deleteSalesmanApplyByIds(ids));
    }
}
